/*
* zzh 20170105
*/

#ifndef _z9_ATOMIC_H
#define _z9_ATOMIC_H


#define z9_compare_and_swap(PTR, OLD, NEW) __sync_bool_compare_and_swap((PTR), (OLD), (NEW))
#define z9_atomic_increase_fetch(PTR) __sync_add_and_fetch(PTR, 1)
#define z9_atomic_decrease_fetch(PTR) __sync_sub_and_fetch(PTR, 1)
#define z9_atomic_fetch_increase(PTR) __sync_fetch_and_add(PTR, 1)
#define z9_atomic_fetch_decrease(PTR) __sync_fetch_and_sub(PTR, 1)
#define z9_fence __sync_synchronize

#endif